import { constantRoutes } from '@/router'
import { getAuthRoutes } from '@/utils/permission'

const state = {
  routes: [],
}

const mutations = {
  SET_ROUTES(state, payload) {
    state.routes = payload
  },
}

const actions = {
  // 生成路由
  GenerateRoutes({ commit }) {
    return new Promise((resolve) => {
      const routes = getAuthRoutes(constantRoutes)
      console.log(routes)
      commit('SET_ROUTES', routes)
      resolve(routes)
    })
  },
}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
